﻿using System;
using System.Threading;
using System.Threading.Tasks;

namespace AwaitDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i < 4; i++)
            {
                DisplayPrimeLongtimeCounts();
            }

            Console.WriteLine("Hello World!");
            Console.ReadLine();
        }
        async static void DisplayPrimeLongtimeCounts()
        {
            Console.WriteLine(await GetLongtimeCounts(4));
            Console.WriteLine("这...");
        }
        static Task<int> GetLongtimeCounts(int i)
        {
            return Task.Run(() =>
            {
                Random rdm = new Random();
                var time = rdm.Next(800, 1000);
                Thread.Sleep(time);
                return i * time;
            });
        }
    }
}
